package com.it.io;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListIOSequence<E> extends AbstractIOSequence<List<E>, E> {

	Iterator<E> it;
	
	@Override
	public void initInput(List<E> input) {
		this.input = input;
		this.it = input.iterator();
	}

	@Override
	public boolean hasInput() {
		return it.hasNext();
	}

	@Override
	public E input() {
		inputIndex++;
		return it.next();
	}

	@Override
	public void initOutput(int size) {
		this.output = new ArrayList<>(size);
	}

	@Override
	public void output(E e) {
		outputIndex++;
		output.add(e);
	}

	@Override
	public List<E> finish() {
		return output;
	}

}